<?php
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec");
ini_set("date.timezone", "Europe/Paris");

$this_day = now();
$pattern = "%Y";
$str_year = mdate($pattern, $this_day);

for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year; $i > 1900; $i--) {
    $year_data[$i] = $i;
}

$user = $user_level == 2 ? 'Administrateur' : 'Utilisateur';
?>

<div id="wrapper-content">
<table class="titrepage" width="100%">
        <tr>
            <td >La liste des <?php echo $user ?></td>
          </tr>
    </table>
        <?php echo form_open_multipart('admin/add_user'.'/'.$user_level)?>

            <table class="list" width="100%" cellpadding="10px" cellspacing="0">
                <tr>
                    <td><label for="user_name">Identifiant <font color="red">*</font></label></td>
                    <td><input type="text" name="user_name" value="<?php echo set_value('user_name'); ?>" id="user_name"/></td>
                    <td><?php echo form_error('user_name')?></td>
                </tr>
                <tr>
                    <td><label for="email">Email <font color="red">*</font></label></td>
                    <td><input type="text" name="email" value="<?php echo set_value('email'); ?>"/></td>
                    <td><?php echo form_error('email')?></td>
                </tr>
                <tr>
                    <td><label for="pass">Mot de passe <font color="red">*</font></label></td>
                    <td><input type="password" name="pass"/></td>
                    <td><?php echo form_error('pass')?></td>
                </tr>
                <tr>
                    <td><label for="confirm_pass">Confirmation du mot de passe <font color="red">*</font></label></td>
                    <td><input type="password" name="confirm_pass"/></td>
                    <td><?php echo form_error('confirm_pass')?></td>
                </tr>
                <tr>
                    <td><label for="first_name">Nom<font color="red">*</font></label></td>
                    <td><input type="text" name="first_name" id="first_name" value="<?php echo set_value('first_name'); ?>"/></td>
                    <td><?php echo form_error('first_name')?></td>
                </tr>
                <tr>
                    <td><label for="last_name">Prénom <font color="red">*</font></label></td>
                    <td><input type="text" name="last_name" id="last_name" value="<?php echo set_value('last_name'); ?>"/></td>
                    <td><?php echo form_error('last_name')?></td>
                </tr>
                <tr>
                    <td><label for="display_name">Nom d'affichage <font color="red">*</font></label></td>
                    <td><input type="text" name="display_name" id="display_name" value="<?php echo set_value('display_name'); ?>"/></td>
                    <td><?php echo form_error('display_name')?></td>
                </tr>
                <tr>
                    <td><label >Image:</label></td>
                    <td><input type="file" name="userfile" id="userfile" size="25"/></td>
                </tr>
                <tr>
                    <td><label for="company">Entreprise <font color="red">*</font></label></td>
                    <td><input type="text" name="company" id="company" value="<?php echo set_value('company'); ?>"/></td>
                    <td><?php echo form_error('company')?></td>
                </tr>
                <tr>
                    <td><label for="dob">Date de naissance</label></td>
                    <td>
                        J : <?php echo form_dropdown('birth_date', $day_data, 1, 'id="day"'); ?>
                        M : <?php echo form_dropdown('birth_month', $dropdown_data, 1, 'id="month"'); ?>
                        A : <?php echo form_dropdown('birth_year', $year_data, $str_year, 'id="year"'); ?>
                    </td>
                </tr>
                <tr>
                    <td><label for="gender">Sex</label></td>
                    <td>
                    <?php
                    $male = array(
                        'name' => 'gender',
                        'id' => 'rad_male',
                        'value' => 'm',
                        'checked' => TRUE,
                        'style' => 'margin:10px',
                    );
                    $female = array(
                        'name' => 'gender',
                        'id' => 'rad_female',
                        'value' => 'f',
                        'checked' => FALSE,
                        'style' => 'margin:10px',
                    );

                    echo 'Masculin' . form_radio($male);
                    echo 'Féminin' . form_radio($female, 'Female');
                    ?>
                </td>
                </tr>
                <tr>
                    <td><label for="phone">Téléphone</label></td>
                    <td><input type="text" name="phone" id="phone" value="<?php echo set_value('phone'); ?>"/></td>
                    <td><?php echo form_error('phone')?></td>
                </tr>
                <tr>
                    <td><label for="mobile">Mobile</label></td>
                    <td><input type="text" name="mobile" id="mobile" value="<?php echo set_value('mobile'); ?>"/></td>
                    <td><?php echo form_error('mobile')?></td>
                </tr>
                <tr>
                    <td><label for="address">Adresse <font color="red">*</font></label></td>
                    <td><input type="text" name="address" id="address" value="<?php echo set_value('address'); ?>"/></td>
                    <td><?php echo form_error('address')?></td>
                </tr>
                <tr>
                    <td></td><td><input type="submit" name="register" id="register" value=" Ajouter "/></td>
                </tr>
            </table>

        <?php echo form_close() ?>
    </form>
</div>